<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue表单输入绑定</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="example-1">
        <input type="text" v-model="msg"/>
        <p>{{ msg }}</p>
        <!-- 文本 -->
        <input type="text"  name="" id="" v-model="message" placeholder="请输入值"/>
        <p>值的变量是: {{ message }}</p>
        <!-- 多行文本 -->
        <span>多行的值是:</span>
        <p style="white-space: pre-line;">{{messages }}</p>
        <br/>
        <textarea v-model="messages" placeholder="请输入多行文本框的值:"></textarea>
        <br/>
        <!-- 复选框 -->
        <input type="checkbox" id="checkbox" v-model="checked">
        <label for="checkbox">{{ checked }}</label>
        <br/>
        <!-- 多个复选框绑定到同一个数组 -->
        <input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
        <label for="jack">Jack</label>
        <input type="checkbox" id="john" value="John" v-model="checkedNames">
        <label for="john">John</label>
        <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
        <label for="Mike">Mike</label>
        <br/>
        <span>选择的同学是:{{ checkedNames }}</span>
        <br/>
        <!-- 单选按钮 -->
        <input type="radio" id="one" value="one" v-model="picked">
        <label for="one">One</label>
        <br/>
        <input type="radio" id="two" value="Two" v-model="picked">
        <label for="two">Two</label>
        <br/>
        <span>单选按钮为: {{ picked }}</span>
        <br/>
        <!-- 选择框 -->
        <select name="" id="" v-model="selected">
            <option  disabled value="">请选择</option>
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <span>选择的是: {{ selected }}</span>
        <br/>
        <!-- 多选时绑定到一个数组 -->
        <select name="" id="" v-model="selected" multiple style="width: 50px;">
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <br/>
        <span>多选的值是: {{ selected }}</span>
        <br/>
        <!-- v-for渲染动态选项 -->
        <select name="" id="" v-model="selected">
            <option value="" v-for="option in options" v-bind:value="option.value">
                {{ option.text }}
            </option>
        </select>
        <span>选择多个值为: {{ selected}}</span>
        <br/>
        <!-- 值绑定 -->
        <input type="radio" v-model="picked" value="a">
        <input type="checkbox" v-model="toggle">
        
    </div>
</body>
<script type="text/javascript">
    const example1 = new Vue({
        el: '#example-1',
        data: {
            msg: 'hello',
            message: '',
            messages: '',
            checked: '',
            checkedNames: [],
            picked: '',
            selected: '',
            selected: [],
            selected: 'A',
            options: [
                { text: 'One', value: 'A' },
                { text: 'Two', value: 'B' },
                { text: 'Three', value: 'C' }
            ]

        }
    })
</script>
</html>